<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        // 定义一个函数，一个参数，将数组中的偶数个挑选出来存入到新数组，并返回该新数组


       
        function selectEven(arrs){//形式参数
            var newArr=[];
            for(var i=0;i<arrs.length;i++){
                if(i%2!=0){// 1    3
                    newArr.push(arrs[i]);//arrs[1]  arrs[3]
                    // newArr[newArr.length]=arrs[i];//newArr[0]=arrs[1]  newArr[1]=arrs[3]
                }
            }
            return newArr;
        }
        var nums=["熊振宇","徐军","找王姐","刘思思"];
        console.log(selectEven(nums));




        // 定义一个函数，一个参数，计算该数组中字符串的个数
        function calcCount(arrs){//形参
            var count=0;
            for(var i=0;i<arrs.length;i++){
                if((typeof arrs[i])=="string"){
                    count++;
                }
            }
            return count;
        }
        var nums=["aa",12,"bb","cc",100,30];
        console.log(calcCount(nums));
        var nums2=["a","b","c","d",1];
        console.log(calcCount(nums2));


        // 定义一个函数，两个参数，计算数组中值等于item元素的出现的次数

        function calcCount2(arrs,item){
            var count=0;
            for(var i=0;i<arrs.length;i++){
                if(arrs[i]==item){
                    count++;
                }
            }
            return count;
        }
        var arrays=["熊","羊","狗","猪","驴","熊"];
        console.log(calcCount2(arrays,"熊"));
    </script>
</head>
<body>
    
</body>
</html>